package com.dayuanit.spring.demo.domain;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Component
public class AnimalZoo {

    @Value("${animal.name}")
    private String name;

    @Autowired(required = false)
    private Fish fish;

//    @Autowired
//    @Qualifier(value = "cat2")
    //第二种方案：Resource解决
//    @Resource(name = "cat2")
    private Cat cat;

    public AnimalZoo() {
        System.out.println("AnimalZoo()");
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Fish getFish() {
        return fish;
    }

    public void setFish(Fish fish) {
        this.fish = fish;
    }

    public Cat getCat() {
        return cat;
    }

    public void setCat(Cat cat) {
        this.cat = cat;
    }
}
